#define _CRT_SECURE_NO_WARNINGS 1
#pragma warning(disable:6031)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define SWAP(arr, i, j) {	\
	int tmp = arr[i];		\
	arr[i] = arr[j];		\
	arr[j] = tmp;			\
}

#define SIZE(a) (sizeof(a) / sizeof(a[0]))

void shuffle(int arr[], int n) {
	srand(time(NULL));
	for (int i = 0; i < n - 1; i++) {
		// [i, n-1]
		int j = rand() % (n - i) + i;
		SWAP(arr, i, j);	
	}
}

void print_array(int arr[], int n) {
	for (int i = 0; i < n; i++) {
		printf("%d ", arr[i]);
	}
	printf("\n");
}

int main(void) {
	int arr[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

	shuffle(arr, SIZE(arr));
	print_array(arr, SIZE(arr));

	return 0;
}